<template>
	<view class="lease_bill_stages">
		<view class="container">
			<view class="pay-status u-p-t-30 u-p-b-40">
				<view class="">
					<image src="@/bundle/static/images/completedicon.png" mode="aspectFit"></image>
				</view>
				<view class="">
					恭喜你，买断成功
				</view>
				<view class="">
					感谢您的支持，如有疑问请联系平台客服
				</view>
			</view>
			<view class="buyout u-m-t-60 row-between">
				<button @click="viewOrder(1)">查看订单</button>
				<button @click="viewOrder(0)">返回首页</button>
			</view>

		</view>

	</view>
</template>

<script>
	import {
		billRepayment
	} from '@/api/lease.js'
	export default {
		data() {
			return {
				reletId: 0, //账单订单id
				orderDetail: {

				},
			}
		},

		methods: {
			
			viewOrder(type){
				if(type==1){
				uni.redirectTo({
					url: '/bundle/pages/lease_order_lists/lease_order_lists?type=5'
				});
					
				}else{
					uni.switchTab({
						url: '/pages/index/index'
					});
				}
			},
			// 初始化数据
			indata() {
				billRepayment({
					id: this.reletId,
					action: 'info'
				}).then(res => {
					if (res.code != 1) return;
					this.orderDetail = res.data;

				})
			},

			//立即支付
			confirmReturn() {
				uni.showLoading({
					title: '正在提交...',
					mask: true
				});
				const id = this.orderDetail.id;
				billRepayment({
					action: 'submit',
					id: id
				}).then(res => {
					if (res.code == 1) {
						const data = res.data;
						this.$toast({
							title: res.msg,
							icon: 'success'
						});
						uni.hideLoading();
						//跳转支付页面
						uni.redirectTo({
							url: `/pages/payment/payment?from=${data.from}&order_id=${data.order_id}`
						})
					}
				}).catch(() => {
					uni.hideLoading();
				})

			},


		},

		onLoad(options) {
			const id = options.id
			this.reletId = id;
		},

		onShow() {
			// this.indata()
		}
	}
</script>

<style lang="scss" scoped>
	.lease_bill_stages {
		padding: 0 24rpx 0 24rpx;
	}

	.container {
		padding: 22px;
		margin-bottom: 20rpx;
		border-radius: 14rpx;
		background-color: #FFFFFF;

		image {
			border-radius: 12rpx;
		}
	}

	.pay-status {
		text-align: center;
		border-bottom: 1rpx dashed #0000001a;

		image {
			width: 112rpx;
			height: 112rpx;
		}

		>view:nth-child(1) {}

		>view:nth-child(2) {
			color: #000000e6;
			font-size: 36rpx;
			font-style: normal;
			font-weight: 500;
			line-height: 36rpx;
			margin: 34rpx 0;
		}

		>view:nth-child(3) {
			color: #00000099;
			font-size: 28rpx;
			font-style: normal;
			font-weight: 500;
			line-height: 28rpx;
		}
	}

	.buyout {
		>button:nth-child(1) {
			padding: 2rpx 90rpx;
			border-radius: 40rpx;
			color: #FFFFFF;
			background: #2482EE;
		}

		>button:nth-child(2) {
			padding: 2rpx 90rpx;
			border-radius: 40rpx;
			color: #2482EE;
			border: 2rpx solid #2482EE;
		}
	}
</style>